package com.eclipse.e0114_java8.课堂案列;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class Test2_匿名内部类_无限流 {

	static List<String> list = Arrays.asList("9", "22", "333", "4444");

	public static void main(String[] args) {

		// 1: 构建Stream
		Stream<String> stream = list.stream();

		// 匿名内部类
//		long count = stream.filter(new Predicate<String>() {
//			public boolean test(String t) {
//				return t.length() > 2;
//			}
//		}).count();
//		System.out.println(count);

		// lambda
		long count1 = stream.filter((t) -> t.length() > 2).count();
		System.out.println(count1);

//		//4.创建无限流 //迭代 
//		Stream<Integer> stream9 = Stream.iterate(0, (x)->x+2); 
//		stream9.limit(10)
//		.forEach(System.out::println);
//		Stream<Double> stream2 = Stream.generate(()->Math.random()); 
//		stream2.limit(5)
//		.forEach(System.out::println);

	}

}
